//
//  SelMapDZViewController.m
//  YaDiuDiu
//
//  Created by 欧洪飞 on 2017/9/30.
//  Copyright © 2017年 jy. All rights reserved.
//

#import "SelMapDZViewController.h"

#import "KuLiCell.h"
#import "KuPersonViewController.h"
@interface SelMapDZViewController ()<UITableViewDelegate,UITableViewDataSource>

@property (nonatomic,strong)UITableView *tableView;

@end

@implementation SelMapDZViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self setBGColor];
    [self showNav:@"所选成员"];
    
    [self loadUI];
    
}

- (void)loadUI{
    _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, ScreenWidth, ScreenHeight-64) style:UITableViewStylePlain];
    _tableView.delegate = self;
    _tableView.dataSource = self;
    _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    [self.view addSubview:_tableView];
    
    
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.datas.count;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    static NSString *cellId = @"Cell";
    KuLiCell *cell = [tableView dequeueReusableCellWithIdentifier:cellId];
    if (!cell) {
        cell = [[[NSBundle mainBundle] loadNibNamed:@"KuLiCell" owner:nil options:nil] lastObject];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    NSDictionary *dic = self.datas[indexPath.row];
    cell.labName.text = [dic objectForKey:@"name"];
    NSString *age = [NSString stringWithFormat:@"%li岁",[[dic objectForKey:@"age"] integerValue]];
    NSString *seniority = [NSString stringWithFormat:@"%li年",[[dic objectForKey:@"seniority"] integerValue]];
    NSString *order = [NSString stringWithFormat:@"%li",[[dic objectForKey:@"order"] integerValue]];
    cell.labAge.text =age;
    cell.labYear.text = seniority;
    cell.labOrder.text = order;
    
    NSString *imgUrl = [NSString stringWithFormat:@"%@%@",[user objectForKey:@"ImageUrl"],[dic objectForKey:@"img"]];
    [cell.imageHead sd_setImageWithURL:[NSURL URLWithString:imgUrl] placeholderImage:[UIImage imageNamed:@"Avatar-sample-187"]];
    
    NSString *star = [NSString stringWithFormat:@"%li",[[dic objectForKey:@"star"] integerValue]];
    NSInteger count = [star integerValue];
    StarView *starView = [[StarView alloc] initWithFrame:CGRectMake(0, 0, 80, 20)];
    starView.showStar = count * 20;
    [cell.starView addSubview:starView];
    
    cell.imageSel.hidden = YES;
    cell.width.constant = 16;//修改约束大小
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 100.0;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    KuPersonViewController *man = [[KuPersonViewController alloc] init];
    NSDictionary *dics = self.datas[indexPath.row];
    man.dic = dics;
    [self.navigationController pushViewController:man animated:YES];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
